package com.efounder.view;

import android.content.Context;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import com.efounder.util.EnvSupportManager;
import com.utilcode.util.StatusBarUtil;

/**
 * 状态栏view占位使用，该view的高度与状态栏高度一致
 * Created by yqs
 * Date: 2019/10/26
 * Time: 13:48
 */
public class StatusPlaceholderView extends View {
    public StatusPlaceholderView(Context context) {
        this(context, null);

    }

    public StatusPlaceholderView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);

    }

    public StatusPlaceholderView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }

    private void initView() {
        //我们通过判断属性开关 来决定是否启用了透明状态栏
        if (EnvSupportManager.isUseTransparentStatus()) {
            this.setVisibility(View.VISIBLE);
        } else {
            this.setVisibility(View.GONE);
        }
//        this.setVisibility(View.GONE);

    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        int widthMode = MeasureSpec.getMode(widthMeasureSpec);
        int widthSpec = MeasureSpec.getSize(widthMeasureSpec);
        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
        int heightSpec = MeasureSpec.getSize(heightMeasureSpec);

//        if (widthMode== MeasureSpec.AT_MOST || widthMode==MeasureSpec.EXACTLY) {
//
//
//        }

        //高度我们要设置成statusbar 的高度
        int measureHeight = StatusBarUtil.getStatusBarHeight(this.getContext());
        setMeasuredDimension(widthSpec, measureHeight);

    }
}
